package com.btkjgc.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.btkjgc.framework.BasicController;
import com.btkjgc.model.UpdateForm;
import com.btkjgc.models.CommonInfo;
import com.btkjgc.service.impl.CommonInfoService_Impl;
import com.btkjgc.service.intf.CommonInfoService_Intf;

@Controller
public class CommonInfoController extends BasicController
{
	static Logger logger = Logger.getLogger(CommonInfoController.class);

	private CommonInfoService_Intf commonInfoService = new CommonInfoService_Impl();

	public static class CommonInfoUpdateForm extends UpdateForm
	{

		private Integer readyFrequence;// 待机时心跳包频率
		private Integer rentFrequence;// 租车时心跳包频率
		private Float deposit;// 押金
		private Integer validTime;// 验证码有效时间(单位：秒)
		private String validNotice;// 短信通知内容，如，"您的验证码是(有效期1分钟)：123456"
		private Integer rewards;// 奖励
		private Integer heartBeatTimeOutMinutes;// 心跳超时时间设置（以分钟为单位）
		private String smsContent1;// 验证码前面的短信内容
		private String smsContent2;// 验证码前面的短信内容
		private Integer levelupMile; // 等级上升所需开的里程数；
		private String latestAndroidVersion;// andoir最新版本号
		private String latestAndroidVersionName;// android最新版本名
		private String latestAndroidVersionUrl;// android最新版下载地址
		private String latestIosversionUrl;// ios最新版本下载地址
		private String latestWeixinAndroidVersionUrl;// 微信android最新版下载地址
		private String latestWeixinIosversionUrl;// 微信ios最新版本下载地址
		private Integer updateCarInfoLogFrequence;// 收集CarInfoLog的频率
		private Double pointCoefficientMiles; // 积分系数

		private Double pointsCoefficient;// 开车里程积分系数
		private Integer sampleNumbersForLeftMiles;// 预测续航里程所需采集的局部电压数量
		private String guidUrl;// 租车策略webview引导界面

		public Integer getReadyFrequence()
		{
			return readyFrequence;
		}

		public void setReadyFrequence(Integer readyFrequence)
		{
			this.readyFrequence = readyFrequence;
		}

		public Integer getRentFrequence()
		{
			return rentFrequence;
		}

		public void setRentFrequence(Integer rentFrequence)
		{
			this.rentFrequence = rentFrequence;
		}

		public Float getDeposit()
		{
			return deposit;
		}

		public void setDeposit(Float deposit)
		{
			this.deposit = deposit;
		}

		public Integer getValidTime()
		{
			return validTime;
		}

		public void setValidTime(Integer validTime)
		{
			this.validTime = validTime;
		}

		public String getValidNotice()
		{
			return validNotice;
		}

		public void setValidNotice(String validNotice)
		{
			this.validNotice = validNotice;
		}

		public String getLatestAndroidVersion()
		{
			return latestAndroidVersion;
		}

		public void setLatestAndroidVersion(String latestAndroidVersion)
		{
			this.latestAndroidVersion = latestAndroidVersion;
		}

		public String getLatestAndroidVersionName()
		{
			return latestAndroidVersionName;
		}

		public void setLatestAndroidVersionName(String latestAndroidVersionName)
		{
			this.latestAndroidVersionName = latestAndroidVersionName;
		}

		public Integer getRewards()
		{
			return rewards;
		}

		public void setRewards(Integer rewards)
		{
			this.rewards = rewards;
		}

		public String getSmsContent1()
		{
			return smsContent1;
		}

		public void setSmsContent1(String smsContent1)
		{
			this.smsContent1 = smsContent1;
		}

		public String getSmsContent2()
		{
			return smsContent2;
		}

		public void setSmsContent2(String smsContent2)
		{
			this.smsContent2 = smsContent2;
		}

		public Integer getLevelupMile()
		{
			return levelupMile;
		}

		public void setLevelupMile(Integer levelupMile)
		{
			this.levelupMile = levelupMile;
		}

		public Integer getUpdateCarInfoLogFrequence()
		{
			return updateCarInfoLogFrequence;
		}

		public void setUpdateCarInfoLogFrequence(
				Integer updateCarInfoLogFrequence)
		{
			this.updateCarInfoLogFrequence = updateCarInfoLogFrequence;
		}

		public Double getPointCoefficientMiles()
		{
			return pointCoefficientMiles;
		}

		public void setPointCoefficientMiles(Double pointCoefficientMiles)
		{
			this.pointCoefficientMiles = pointCoefficientMiles;
		}

		public String getLatestAndroidVersionUrl()
		{
			return latestAndroidVersionUrl;
		}

		public void setLatestAndroidVersionUrl(String latestAndroidVersionUrl)
		{
			this.latestAndroidVersionUrl = latestAndroidVersionUrl;
		}

		public String getLatestIosversionUrl()
		{
			return latestIosversionUrl;
		}

		public void setLatestIosversionUrl(String latestIosversionUrl)
		{
			this.latestIosversionUrl = latestIosversionUrl;
		}

		public String getLatestWeixinAndroidVersionUrl()
		{
			return latestWeixinAndroidVersionUrl;
		}

		public void setLatestWeixinAndroidVersionUrl(
				String latestWeixinAndroidVersionUrl)
		{
			this.latestWeixinAndroidVersionUrl = latestWeixinAndroidVersionUrl;
		}

		public String getLatestWeixinIosversionUrl()
		{
			return latestWeixinIosversionUrl;
		}

		public void setLatestWeixinIosversionUrl(
				String latestWeixinIosversionUrl)
		{
			this.latestWeixinIosversionUrl = latestWeixinIosversionUrl;
		}

		public Double getPointsCoefficient()
		{
			return pointsCoefficient;
		}

		public void setPointsCoefficient(Double pointsCoefficient)
		{
			this.pointsCoefficient = pointsCoefficient;
		}

		public Integer getHeartBeatTimeOutMinutes()
		{
			return heartBeatTimeOutMinutes;
		}

		public void setHeartBeatTimeOutMinutes(Integer heartBeatTimeOutMinutes)
		{
			this.heartBeatTimeOutMinutes = heartBeatTimeOutMinutes;
		}

		public Integer getSampleNumbersForLeftMiles()
		{
			return sampleNumbersForLeftMiles;
		}

		public void setSampleNumbersForLeftMiles(
				Integer sampleNumbersForLeftMiles)
		{
			this.sampleNumbersForLeftMiles = sampleNumbersForLeftMiles;
		}

		public String getGuidUrl()
		{
			return guidUrl;
		}

		public void setGuidUrl(String guidUrl)
		{
			this.guidUrl = guidUrl;
		}
	}

	@RequestMapping(value = "common_info", method = { RequestMethod.GET,
			RequestMethod.POST })
	public ModelAndView process(HttpServletRequest request)
	{
		ModelAndView mv = super.process(request);
		CommonInfo info = commonInfoService.getCommonInfo();
		mv.addObject("CommonInfo", info);
		return mv;
	}

	public void update(HttpServletRequest request, ModelAndView mv,
			CommonInfoUpdateForm form)
	{
		int id = Integer.parseInt(form.getId());
		commonInfoService.updateCommonInfoById(id, form);
	}

}
